package com.example.io_demo.io;

import com.example.io_demo.entity.People;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

/**
 * @author zhaoyunlong
 * @date 2020/11/2
 * @description
 */
public class ObjectDemo {


    public static void main(String[] args) {

        try (FileOutputStream fileOutputStream = new FileOutputStream("abc.txt");
             ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
            People people = new People("zhao", "123");
            objectOutputStream.writeObject(people);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
